using System;
using System.Collections.Generic;
using UnityEngine;

public class ChessComponentModel : BaseComponentModel
{
    public DataModel<Vector3> posDM;
    public DataModel<(string, string)> imageDM;
    public BaseChess chess;
    public DataModel<bool> isSelectedDM;
    public ChessComponentModel(BaseChess chess)
    {
        posDM = new DataModel<Vector3>(new Vector3(0, 0, -2));
        this.chess = chess;
        imageDM = new DataModel<(string, string)>(("ChessPieces", imageDict[chess.GetType()][chess.GetCamp()]));
        isSelectedDM = new DataModel<bool>(false);
    }
    public void UpdatePos(Vector3 v3)
    {
        posDM.Set(v3);
    }
    static private Dictionary<Type, string[]> imageDict = new Dictionary<Type, string[]>()
    {
        [typeof(ChessBing)] = new string[2] { "hong_bing", "hei_zu" },
        [typeof(ChessChe)] = new string[2] { "hong_che", "hei_che" },
        [typeof(ChessMa)] = new string[2] { "hong_ma", "hei_ma" },
        [typeof(ChessPao)] = new string[2] { "hong_pao", "hei_pao" },
        [typeof(ChessShi)] = new string[2] { "hong_shi", "hei_shi" },
        [typeof(ChessShuai)] = new string[2] { "hong_shuai", "hei_jiang" },
        [typeof(ChessXiang)] = new string[2] { "hong_xiang", "hei_xiang" },
    };
    public void ChangeSelectedStatus(bool status)
    {
        isSelectedDM.Set(status);
    }
}
